<extend name="./app/Tpl/Public/template.html" />
<block name="content_body">
	<div class="pad-lr-10">
		<form name="form_search" id="form_search" action="{:U('showProdCancelList')}" method="post">
			<input type="hidden" name="order_status" value="{$search.order_status}">
		    <table width="100%" cellspacing="0" class="search-form">
		        <tbody>
		            <tr>
			            <td>
				            <div class="explain-col">							
								<input type="text" name="order_code" value="{$search.order_code}" placeholder="订单号">
								<input type="text" name="prod_name" value="{$search.prod_name}" placeholder="商品名称">

								<input type="button"  name="form_search_btn_search"  value="查询" onclick="document.forms['form_search'].submit()"/>	
				        	</div>
			            </td>
		            </tr>
		        </tbody>
		    </table>
	    </form>
	    <form  name="form_list" id="form_list" action="{:U('index')}" method="post">
		    <div class="table-list">		
			    <table width="100%" cellspacing="0">
			        <thead>
			            <tr>
			            	<th width="50" align="center">订单号</th> 
			            	<th width="250" align="center">商品名称</th>
			            	<th width="250" align="center">规格</th>  
			            	<th width="100" align="left">购买数量</th> 
			            	<th width="100" align="left">退货数量</th>               
			                <th width="80" align="left">下单时间</th>
			      			<th align="left">操作</th>
			            </tr>
			        </thead>
			    	<tbody>
						<volist name="list" id='val'>
				        <tr>
				        	<td align="center">{$val.order_code}</td>
				        	<td align="center">{$val.prod_name}</td>
				            <td align="left">{$val.prod_spec|m_prod_spec=$val['prod_spec_qty'],$val['prod_spec_unit']}</td>
				            <td align="left">{$val.prod_num}</td>
				            <td align="left">{$val.prod_cancel_num}</td>
				            <td align="left">{$val.cust_order_time|date="H:i:s",###}</td>
				            <td align="left" class="btn" id="action_text{$val.id}">
				            	<a class="link_btn" href="#" onclick="doUpdStock('{$val.order_code}','{$val.id}',1)" >入库</a>
				            	<a class="link_btn" href="#" onclick="doUpdStock('{$val.order_code}','{$val.id}',2)" >取消入库</a>
				            </td>
				        </tr>
				        </volist>
			    	</tbody>
			    </table>
	
			    <div class="btn">
					<div id="pages">{$page}</div>
			    </div>
	    	</div>
	    </form>
	</div>
	<div id="dialog_content" title="弹出框"></div>
<script type="text/javascript">

function doUpdStock(order_code,id,prod_cancel_stock_status){
	//document.location.href = "/cart/doadd.html?prod_id="+prod_id+"&num="+num+"&edittype="+edittype;
	var alertMsg = "";
	if(prod_cancel_stock_status==1){
		alertMsg = "确定做【入库】操作？";
	}else if(prod_cancel_stock_status==2){
		alertMsg = "确定做【不入库】操作？"
	}else{
		return;
	}
	if(!confirm(alertMsg)){
		return;
	}
	$.ajax({
		'async': true, 
        'url': "{:U('Order/OrderManage/doUpdStock')}",
        'dataType': "json",
        'data': {'order_code':order_code,'id':id,'prod_cancel_stock_status':prod_cancel_stock_status},
        'success': function (data) {
        	if(data['error']=='0'){
	        	$("#action_text"+id).html('操作成功');
        	}else{
        		alert(data['message']);
        	}
        }
    });
}

</script>
</block>